// MySocket.h: interface for the MySocket class.
//
//////////////////////////////////////////////////////////////////////

#pragma once

#include "stdafx.h"
#include<winsock2.h>
#include <string>
#include <map>
#include <Iphlpapi.h>
#include <vector>
using namespace std;

class MySocket  
{
public:
	void EndThisClient();
	bool ReceiveFromClient(char *receiveBuffer, int receiveBufferLength, int& receiveLength);
	bool SendToClient(char *sendBuffer, int sendBufferLength);
	void NextClient();
	bool BeginListen(int port);
	bool Receive(char *receiveBuffer, int receiveBufferLength, int& receiveLength);
	bool Send(char *sendBuffer, int sendBufferLength);
	bool Connect(char *ipAddress, int port);
	bool SendPostHttp(string sendToAddress, string postContent);
	bool SendGetHttp(string aStrAddress);
	wstring GetSocketLocalIp();
	int GetSocketLocalPort();
	int GetSocketRemotePort();
	wstring GetSocketRemoteIp();
	static string GetDomainNameByIpAddress(string ip);
	static string GetIpAddressByDomainName(string domainName);
	static vector<wstring> GetAllNetworkCardMac();
	static vector< vector<wstring> > GetAllNetworkCardIp();
	MySocket();
	virtual ~MySocket();

private:
	string GetRequestAddressHttpHeaderGetLine(string aStrRequestAddress);
	string GetRequestAddressHost(string aStrRequestAddress);

private:
	SOCKET m_clientSocket;
	SOCKET m_listenSocket;
	SOCKET m_socket;
	static int m_objectNumber;
	bool m_isFirstUseNextClient;
};
